package com.yang.controller.admin;

import com.yang.bean.MarketCoupon;
import com.yang.bean.common.BasePageInfo;
import com.yang.bean.common.BaseRespVo;
import com.yang.bean.common.CommonData;
import com.yang.bean.szy.MarketCouponBO;
import com.yang.bean.szy.MarketCouponUpdateBO;
import com.yang.bean.szy.MarketCouponVO;
import com.yang.service.admin.AdminCouponService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("admin/coupon")
public class AdminCouponController {
    @Autowired
    AdminCouponService adminCouponService;

    @RequestMapping("list")
    public BaseRespVo<CommonData<MarketCoupon>> queryAllCoupon(BasePageInfo info, String name,Integer type,Integer status) {
        BaseRespVo<CommonData<MarketCoupon>> baseRespVo = adminCouponService.queryAllCoupon(info, name, type,status);
        return baseRespVo;
    }

    @RequestMapping("create")
    public BaseRespVo<MarketCouponVO> createCoupon(@RequestBody MarketCouponBO marketCouponBO) {
        BaseRespVo<MarketCouponVO> boBaseRespVo = adminCouponService.createCoupon(marketCouponBO);
        return boBaseRespVo;
    }

    @RequestMapping("update")
    public BaseRespVo<MarketCouponUpdateBO> updateCoupon(@RequestBody MarketCouponUpdateBO marketCouponUpdateBO) {
        BaseRespVo<MarketCouponUpdateBO> baseRespVo = adminCouponService.updateCoupon(marketCouponUpdateBO);
        return baseRespVo;
    }

    @RequestMapping("delete")
    public BaseRespVo deleteCoupon(@RequestBody MarketCoupon marketCoupon) {
        adminCouponService.deleteCoupon(marketCoupon);
        return BaseRespVo.ok();
    }

    @RequestMapping("listuser")
    public BaseRespVo<CommonData> queryListuser(Integer page, Integer limit, Integer couponId, String sort, String order) {
        BaseRespVo<CommonData> baseRespVo = adminCouponService.queryListuser(page, limit, couponId, sort, order);
        return BaseRespVo.ok(baseRespVo);
    }

    @RequestMapping("read")
    public BaseRespVo<MarketCoupon> queryCoupon(Integer id) {
        BaseRespVo<MarketCoupon> baseRespVo = adminCouponService.queryCoupon(id);
        return baseRespVo;
    }
}
